package org.walkframework.apps.test.business.base;

import com.alibaba.druid.filter.config.ConfigTools;
import org.walkframework.boot.cache.properties.RedisProperties;
import org.walkframework.boot.cache.util.EncryptUtil;
import org.walkframework.boot.ehdb.config.DruidRSAKeys;
import org.walkframework.boot.ehdb.util.DruidConfigTool;

/**
 * 类注释
 *
 * @author 尾生
 * @since 2024/4/9
 */
public class PasswordUtil {

    public static void main(String[] args) throws Exception {
        // 默认未引入统一密码管理模块，因此密码加密使用组件各自的默认机制
        // ehdb数据源配置密码
        DruidConfigTool.encrypt("sluggard-demo");

        // 数据源配置密码解密
        System.out.println(ConfigTools.decrypt(DruidRSAKeys.PUBLIC_KEY, "TMwPWKmrLBeO3R9ktQ8pyUae/e4FbbToYTzlkCJk2HUrh020XptZQ9lnaZvCO6ibCJ3+JHu5CxOsf+2WOjOPXA=="));

        // redis密码配置
        System.out.println(new EncryptUtil(RedisProperties.DECRYPT_KEY).encrypt("PsUV%V2PTN"));
    }
}
